<!-- 搜索表单 -->
<template>
  <ele-card :body-style="{ paddingBottom: '2px' }">
    <el-form label-width="72px" @keyup.enter="search" inline>
      <el-form-item label="类型">
        <el-radio-group v-model="form.listType" @change="search">
          <el-radio-button label="全部">全部</el-radio-button>
          <el-radio-button label="即将到期">即将到期</el-radio-button>
          <el-radio-button label="已过期">已过期</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <br />
      <el-form-item label="账单分类">
        <el-radio-group v-model="form.cate" @change="search">
          <el-radio-button label="全部">全部</el-radio-button>
          <el-radio-button label="分期">分期</el-radio-button>
          <el-radio-button label="垫付">垫付</el-radio-button>
          <el-radio-button label="欠款">欠款</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <br />
      <el-form-item label="状态">
        <el-radio-group v-model="form.repay_status" @change="search">
          <el-radio-button label="全部">全部</el-radio-button>
          <el-radio-button :label="0">待还款</el-radio-button>
          <el-radio-button :label="1">已还清</el-radio-button>
        </el-radio-group>
      </el-form-item>
      <br />
      <el-form-item label="所属区域">
        <area-radio v-model="form.area_id" @change="search" :other="true" />
      </el-form-item>
      <br />
      <el-form-item label="债主">
        <el-input v-model.trim="form.grandfather" />
      </el-form-item>
      <el-form-item label="车队名称">
        <el-input v-model.trim="form.company" />
      </el-form-item>
      <el-form-item label="车牌号码">
        <el-input v-model.trim="form.plate_number" />
      </el-form-item>

      <el-form-item label-width="16px">
        <el-button type="primary" @click="search">查询</el-button>
      </el-form-item>
    </el-form>
  </ele-card>
</template>

<script setup>
  import { ref } from 'vue';

  import { useFormData } from '@/utils/use-form-data';
  import AreaRadio from '@/components/AreaRadio/index.vue';

  const emit = defineEmits(['search']);

  const props = defineProps({
    /** 弹窗是否打开 */
    listType: {
      type: String,
      default: '全部'
    }
  });

  /** 表单数据 */
  const [form] = useFormData({
    cate: '全部',
    listType: props.listType,
    company: '',
    area_id: 0,
    plate_number: '',
    grandfather: '',
    repay_status: 0
  });

  /** 搜索 */
  const search = () => {
    console.log(form);
    emit('search', { ...form });
  };
</script>
